//body preloader
$(window).on('load', function() { // makes sure the whole site is loaded 
  $('#status').fadeOut(); // will first fade out the loading animation 
  $('#preloader').delay(350).fadeOut('slow'); // will fade out the white DIV that covers the website. 
  $('body').delay(350).css({'overflow':'visible'});
})
//full slider
$(document).ready(function(){
	var swiper = new Swiper('.swiper-container', {
	  navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
      },
    });
});
//Partner slider
$(document).ready(function(){
	var Swiper2 = new Swiper ('.partner-swiper', {
		loop: true,
		//slidesPerView: 5,
		//spaceBetween: 80,
		autoplay: {
			delay: 5000,
			},
		breakpoints: {
			640: {
			  slidesPerView: 2,
			  spaceBetween: 20,
			},
			768: {
			  slidesPerView: 4,
			  spaceBetween: 40,
			},
			1024: {
			  slidesPerView: 5,
			  spaceBetween: 50,
			},
		  }
	});
});
//back to top button 
$("#back-top").hide();
	$(window).scroll(function(){
	
	if($(this).scrollTop()>900){
	 
	$("#back-top").fadeIn()}else{
	$("#back-top").fadeOut()}});
	$("#back-top a").click(function(){
	$("body,html").animate({scrollTop:0},800);return false})

//dropdown menubar on hover
const $dropdown = $(".dropdown");
const $dropdownToggle = $(".dropdown-toggle");
const $dropdownMenu = $(".dropdown-menu");
const showClass = "show";

$(window).on("load resize", function() {
  if (this.matchMedia("(min-width: 768px)").matches) {
    $dropdown.hover(
      function() {
        const $this = $(this);
        $this.addClass(showClass);
        $this.find($dropdownToggle).attr("aria-expanded", "true");
        $this.find($dropdownMenu).addClass(showClass);
      },
      function() {
        const $this = $(this);
        $this.removeClass(showClass);
        $this.find($dropdownToggle).attr("aria-expanded", "false");
        $this.find($dropdownMenu).removeClass(showClass);
      }
    );
  } else {
    $dropdown.off("mouseenter mouseleave");
  }
});

//header fixed 
$(window).scroll(function(){
    if ($(this).scrollTop() > 200) {
       $('.navfix').addClass('d-block');
    } else {
       $('.navfix').removeClass('d-block');
    }
});

//portfolio tabs JS
$(function () {
	var filterList = {
		init: function () {
			// MixItUp plugin
			// http://mixitup.io
				$('#portfoliolist').mixItUp({
  				selectors: {
    			  target: '.portfolio',
    			  filter: '.filter'
    		  },
    		  load: {
      		  filter: '.paper,.plastic,.aluminium'  
      		}     
				});								
			
			}
		};
		// Run the show!
		filterList.init();
	});

//faq plus minus	
$(document).ready(function(){
        // Add minus icon for collapse element which is open by default
        $(".collapse.show").each(function(){
        	$(this).prev(".card-header").find(".fa").addClass("fa-minus-square").removeClass("fa-plus-square");
        });
        
        // Toggle plus minus icon on show hide of collapse element
        $(".collapse").on('show.bs.collapse', function(){
        	$(this).prev(".card-header").find(".fa").removeClass("fa-plus-square").addClass("fa-minus-square");
        }).on('hide.bs.collapse', function(){
        	$(this).prev(".card-header").find(".fa").removeClass("fa-minus-square").addClass("fa-plus-square");
        });
    });

//terms and policy spyscroll
$(document).ready(function(){
  $('body').scrollspy({target: ".policy-list", offset: 10});   
});
